/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vue;

import controleur.MenuListener;
import modele.Plateau;
import java.awt.*;
import java.io.*;

import javax.imageio.*;
import javax.swing.*;
/**
 *
 * @author Puissnce4
 */
public class Fenetre extends JFrame{
    
    private Menu menu;
    private JMenuBar menuBar;
    
    public Fenetre(){
        menu = new Menu();
        setContentPane(menu);
        
        MenuListener listener = new MenuListener(this);
        menu.addJouerListener(listener);
        createMenuBar(listener);
        
        setTitle("Puissance 4");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setResizable(true);
        pack();
        setLocationRelativeTo(null);
        setVisible(true);
    }
    
    private void createMenuBar(MenuListener listener) {
		menuBar = new JMenuBar();
		JMenu partie = new JMenu("Partie");
		JMenuItem close = new JMenuItem("Quitter le jeu");
		JMenuItem menu = new JMenuItem("Retour au menu");

		menu.setActionCommand("menu");
		close.setActionCommand("close");
		menu.addActionListener(listener);
		close.addActionListener(listener);

		menu.setEnabled(false);
		partie.add(menu);
		partie.addSeparator();
		partie.add(close);

		menuBar.add(partie);
		menuBar.add(Box.createHorizontalStrut(240));
		setJMenuBar(menuBar);
    }
    
    public Menu getMenu(){
        return menu;
    }
    
    private void changeContentPane(Container container) {
        setContentPane(container);
        validate();
        repaint();
    }
    
    public void changeToPlateau(){
        getContentPane().removeAll();
        changeContentPane(new Plateau());
    }
}
